<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class UserEdu extends Model
{
    use HasFactory;
    protected $fillable = [
        'user_id',
        'school',
        'type',
        'edu',
        'degree',
        'major',
        'cert',
        'network_cert',
        'degree_cert',
        'numbers',
        'in_date',
        'graduate_date',
        'degree_numbers',
        'system',

    ];

    const POSTONLY = [
        'user_id',
        'school',
        'type',
        'edu',
        'degree',
        'major',
        'cert',
        'network_cert',
        'degree_cert',
        'numbers',
        'in_date',
        'graduate_date',
        'degree_numbers',
        'system',
    ];

    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
    }

    public function project()
    {
        return $this->hasOne(Project::class,'id','project_id')->select('id','title','status');
    }

    public function user()
    {
        return $this->hasOne(User::class,'id','user_id')->select('id','name','status');
    }
}
